<!--提币记录-->
<template>
  <list class="all bg1">
    <refresh class="list-size" :display="refreshing?'show':'hide'" @refresh="onrefresh">
      <loading-indicator class="list-load"></loading-indicator>
    </refresh>
    
    <cell v-if="datas && !datas.length" class="list-tips">
      <VTips text="暂无内容" />
    </cell>

    <template v-else-if="datas">

      <cell v-for="(item, index) in datas" v-bind:key="index">

        <div class="cell bg2" @click="infoClick(item)">
          <div class="row acenter mb20">
            <text class="font32 text2 all mr20">{{"- "+item.amount+" "+item.coinType}}</text>
            <text class="font30 text3">{{T('普通提币')}}</text>
          </div>

          <div class="row acenter">
            <text class="font24 text3 all mr20">{{item.tsStr}}</text>
            <text class="font24 text2">{{item.stateStr}}</text>  
            <LImage class="img-arrow" :src="Config.img('jiantou_lan.png')"></LImage> 
          </div>
        </div>
        
        <div class="genduo" v-if="index == datas.length - 1">
          <text class="font22 text3">{{T('没有更多数据')}}</text>
        </div>
      </cell>
    </template>
  </list>
</template>

<script>


//功能
import jmodal from "@/_js/modal";
import jhttps from "@/_js/https";
import jnavigator from "@/_js/navigator";
import jconfig from "@/_js/config";
import jtime from "@/_js/time";
import jmath from "@/_js/math";


const weexFunction = weex.requireModule("WeexFunction");

import I18N from "@/_i18n/i18n";
var T = I18N.t;
weexFunction.setTitle(T('提币记录'));

import VTips from "@/_public/VTips"
export default {

  components: {
    VTips
  },

  data() {
    return {
      T:T,
      Config:jconfig,
      
      refreshing:false, //true 显示刷新
      datas:undefined,
    };
  },

  created() {   
    var param = weex.config;
    this.exchangeName = param.exchangeName;
    this.onrefresh();
  },

  computed: {
  },

  methods: {

    onrefresh() {
      if (this.refreshing) return;
      this.refreshing = true;
      this.httpGetWithdrawalRecord();
    },

    initData(datas) {

      for (let index = 0; index < datas.length; index++) {

        var data = datas[index];

        data.tsStr = jtime.getTime(data.createTime, 'y/M/d H:m');

        data.num = jmath.jian(data.amount, data.fee);

        switch (Number(data.state)) {
          case 0:
            data.stateStr = '等待确认'
            break;
          case 1:
            data.stateStr = '确认到账'
            break;
          case 2:
            data.stateStr = '提币成功'
            break;
          case 8:
            data.stateStr = '因该币种暂停充值而未到账，恢复充值后自动到账'
            break;
          case 11:
            data.stateStr = '命中黑名单地址'
            break;
          case 12:
            data.stateStr = '账户或充值被冻结'
            break;
          case 13:
            data.stateStr = '子账户充值拦截'
            break;
          default:
            data.stateStr = '提币失败'
            break;
        }
      }
      return datas;
    },

    /********************************* HTTP*/
    //http提币记录
    httpGetWithdrawalRecord() {

      var param = {'transferType':"WITHDRAWAL"};
      jhttps.post("uniswap/queryWithdrawalRecord",param,true,(data) => {

        this.refreshing = false;
        if (data.status == 200) {
          this.datas = this.initData(data.data);
        } else {
          jmodal.toast(data.msg);
        }
      });
    },

    /********************************* 点击*/
    //详情信息
    infoClick(item){
      var param = {'item':item}
      jnavigator.open("", "home/BkTxInfo", param);
    },
  },
};

</script>


<style src="@/_css/style.css" ></style>
<style scoped>
.cell {
  border-radius: 24px;
  padding: 30px;

  margin-top: 20px;
}
.img-arrow {
  width: 8px;
  height: 13px;
  margin-left: 10px;
}

.genduo {
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 750px;
  height: 100px;
}
</style>
